////////////////////////////////////////////////////////////////////////////////
//
//  FLYING KIWI BV
//  Copyright 2010 Flying Kiwi BV
//  All Rights Reserved.
//
//  NOTICE: Flying Kiwi permits you to use, modify, and distribute this file
//  in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////
package plantool.display.windows {
	//--------------------------------------------------------------------------
	//  Imports
	//--------------------------------------------------------------------------
	import kiwi.events.EventDispatcher;
	import kiwi.utils.Validation;
	
	import plantool.helpers.ClassHelper;
	
	//--------------------------------------------------------------------------
	//  [Metadata (Events, Style, Effects etc)]
	//--------------------------------------------------------------------------
	
	//--------------------------------------------------------------------------
	//  Class declaration
	//--------------------------------------------------------------------------
	public class WindowManager extends EventDispatcher {
		//--------------------------------------------------------------------------
		//Class constants
		//--------------------------------------------------------------------------
		
		//--------------------------------------------------------------------------
		//Class variables
		//--------------------------------------------------------------------------
		private static var _instance:WindowManager 			= null;
		private var _windowTypes:Vector.<Class>				= null;
		private var _windows:Vector.<BaseWindow>			= null;
		
		//--------------------------------------------------------------------------
		//Class properties
		//--------------------------------------------------------------------------
		
		//--------------------------------------------------------------------------
		//Constructor and Destructor
		//--------------------------------------------------------------------------
		public function WindowManager(pvt:PrivateConstructorClass) {
			super();
		}
		
		//--------------------------------------------------------------------------
		//Class methods
		//--------------------------------------------------------------------------
		public static function getInstance():WindowManager {
			//check if instance exists
			if (!Validation.isSet(_instance)) {
				_instance = new WindowManager(new PrivateConstructorClass);
			}
			
			//return the instance
			return _instance;
		}
		
		protected override function init():void {
			_windowTypes 	= new Vector.<Class>();
			_windows 		= new Vector.<BaseWindow>();
		}
		
		public function registerWindowType(type:Class):void {
			//register windowtype
			if (_windowTypes.indexOf(type) == -1) {
				_windowTypes.push(type);
			}
		}
	}
}


//--------------------------------------------------------------------------
//END OF PACKAGE
//Define the PrivateConstructorClass here so an instance cannot be by anyone
//except for the class defined in the above package
//--------------------------------------------------------------------------
class PrivateConstructorClass {
	//--------------------------------------------------------------------------
	//Constructor and Destructor
	//--------------------------------------------------------------------------
	public function PrivateConstructorClass() {
	}
}